package ink.lovejinhu.leetcode;

/**
 * @author jinhu
 * created 2021-07-20 11:18
 */
public class Solution_0492 {
    /**
     * 构造矩形
     *
     * @param area
     * @return
     */
    public int[] constructRectangle(int area) {
        int[] res = new int[2];
        for (int l = area, w = 1; l >= w; ) {
            if (l * w == area) {
                res[0] = l;
                res[1] = w;
                l--;
                w++;
            } else if (l * w > area) {
                l--;
            } else {
                w++;
            }
        }
        return res;
    }

    public static void main(String[] args) {
        Solution_0492 solution_0492 = new Solution_0492();
        int[] ints = solution_0492.constructRectangle(122122);
        for (int i = 0; i < ints.length; i++) {
            System.out.println(ints[i]);
        }
    }
}
